<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>博客正文</title>
		<link rel="stylesheet" href="css/conmmon.css">
		<link rel="stylesheet" href="css/blog_content.css">
		<link rel="stylesheet" href="editor.md/css/editormd.preview.min.css" />
		<script src="js/jquery.min.js"></script>
		<script src="editor.md/editormd.js"></script>
		<script src="editor.md/lib/marked.min.js"></script>
		<script src="editor.md/lib/prettify.min.js"></script>
		<script src="js/urlutils.js"></script>
		<script src="js/logout.js"></script>
	</head>
	<body>
		<div class="nav">
			<img src="img/logo2.jpg" alt="">
			<span class="title">我的博客系统</span>
			<span class="spacer"></span>
			<a href="blog_list.html">博客论坛</a>
			<a href="myblog_list.html">我的博客</a>
			<a href="javascript:logout()">注销</a>
		</div>
		<div class="container">
			<div class="container-left">
				<div class="card">
					<img id="photo" src="img/avatar.png" class="avtar" alt="">
					<h3 id="username"></h3>
					<a href="http:www.github.com">github 地址</a>
					<div class="counter">
						<span>文章</span>
					</div>
					<div class="counter">
						<span id="artcount"></span>
					</div>
				</div>
			</div>
			<div class="container-right">
				<div class="blog-content">
					<h3 id="title"></h3>
					<div class="date">
						发布时间:<span id="createtime"></span>
						|
						阅读量:<span id="rcount"></span>
					</div>
					<div id="editorDiv"></div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var id=getParamValue("id");
			var editormd;
			function initEdit(md){
				editormd = editormd.markdownToHTML("editorDiv", {
				markdown : md, // Also, you can dynamic set Markdown text
				// htmlDecode : true,  // Enable / disable HTML tag encode.
				// htmlDecode : "style,script,iframe",  // Note: If enabled, you should filter some dangerous HTML tags for website security.
				});
			}
			
			function init(){
				if(id==null||id<=0){
					alert("参数有误");
					return false;
				}
				jQuery.ajax({
					url:"/art/detail",
					type:"GET",
					data:{
						"id":id
					},
					success:function(res){
						if(res.code==200&&res.data!=null){
							var user=res.data.userinfo;
							var art=res.data.articleinfo;
							if(user!=null){
								jQuery("#username").html(user.username);
								jQuery("#artcount").html(user.artCount);
							}else{
								alert("查询失败："+res.msg);
							}
							if(art!=null){
								jQuery("#title").html(art.title);
								jQuery("#createtime").html(art.createtime);
								jQuery("#rcount").html(art.rcount);
								initEdit(art.content);
							}else{
								alert("查询失败："+res.msg);
							}
						}else{
							alert("查询失败："+res.msg);
						}
					}
				});
			}
			init();
			
			function incrementrcount(){
				if(id==null||id<=0){
					alert("参数有误");
					return false;
				}
				jQuery.ajax({
					url:"/art/increment_rcount",
					type:"POST",
					data:{
						"id":id
					},
					success:function(res){}
				});
			}
			incrementrcount();
		</script> 
	</body>
</html>